var ownShopIds=new Array();
var toOwnShopIds=new Array();
var ownPostIds=new Array();
var toOwnPostIds=new Array();

//初始化form
function resetForm(){
	$("#shopName2").html("");//
	$("#Name").val(""); 
	$("#LoginName2").val(""); 

	var htm="<option value='0'>正常</option><option value='1'>停用</option>"
	$("#Status").html(htm); 
	var  htm1="<option value='1'>男</option><option value='0'>女</option>"
	$("#Sex").html(htm1); 
	$("#IDNumber").val(""); 
	$("#Address").val(""); 
	$("#Tel").val(""); 
	$("#Mp").val(""); 
	$("#Email").val(""); 
	$("#ZipCode").val(""); 
	$("#DeptName").val(""); 
}
//===========增加的部分===============
function showAddPersonnel(){    //  编辑人员信息
	$("#shopName2").html("");//
	$("#Name").val(""); 
	$("#LoginName2").val(""); 

	var htm="<option value='0'>正常</option><option value='1'>停用</option>";
	$("#Status").html(htm); 
	var  htm1="<option value='1'>男</option><option value='0'>女</option>";
	$("#Sex").html(htm1); 
	$("#IDNumber").val(""); 
	$("#Address").val(""); 
	$("#Tel").val(""); 
	$("#Mp").val(""); 
	$("#Email").val(""); 
	$("#ZipCode").val(""); 
	$("#DeptName").val(""); 
	$("#onlyPost").val("");
	$("#doflag").val(1);
	editorHtml = "";
	$("#ownShopList tbody").empty();
	$("#ownPostList tbody").empty();

	if(userType==1&&IsNotEmpty(defaultShopId)&&IsNotEmpty(defaultShopName)){
		var htm="<option>"+defaultShopName+"</option>";
		toOwnShopIds.push(defaultShopId);
		mainShopId=defaultShopId;
		$("#shopName2").html(htm);
		$("#ownShopList tbody").append("<tr></tr>");
		var htm="<td>"+defaultShopId+"</td><td>"+defaultShopName+"</td><td><input class=\"del\" type=\"button\" value=\"主店不可删除\"></td>"
		$("#ownShopList tbody tr:last").append(htm);	
	}

	$("#yinying1,#window_change").show();	
	addMargin($("#Postset"));
			
}
//=============================	

//保存 shopids
function saveOwnShopIds(){
	toOwnShopIds=new Array();
	var shopCount=0;
	$("#ownShopList tbody tr").each(function(){
		var shopId=$(this).find("td:first").html();
		toOwnShopIds.push(shopId);
		shopCount++;
	})
	if(shopCount==0){
		$("#shopName2").html("<option>您还未选择个店铺</option>");

	}else{
	if(shopCount==1){
		$("#shopName2").html("<option>"+ $("#ownShopList tbody tr:first ").find("td").next().html()+"</option>");
	}else if(shopCount>1){
		$("#shopName2").html("<option>已选择"+shopCount +"个店铺</option>");
		
	}			
	}
	$("#personShop").hide();
	$("#yinying,#yinyingCenter").hide();
}
function saveOwnPostIds(){
	toOwnPostIds=new Array();
	$("#ownPostList tbody tr").each(function(){
		var postId=$(this).find("td:first").find("input").val();
		toOwnPostIds.push(postId);
	})
	if(toOwnPostIds.length>0){
		$("#onlyPost").val("已选择"+toOwnPostIds.length+"种岗位");
	}else{
		$("#onlyPost").val("未选择岗位");

	}
	
	$("#personPost").hide()
	$("#yinying,#yinyingCenter").hide();

}

function saveOwnPostIdsBydelete(){
	toOwnPostIds=new Array();
	$("#ownPostList tbody tr").each(function(){
		
		var postId=$(this).find("td:first").find("input").val();
		toOwnPostIds.push(postId);
	})
	if(toOwnPostIds.length>0){
		$("#onlyPost").val("已选择"+toOwnPostIds.length+"种岗位");
	}else{
		$("#onlyPost").val("未选择岗位");

	}
	

}